<?php
/**
 * EmailListItem Model Class File
 *
 * @package
 * @author
 */

/**
 * This is the model class for table "{{emaillistitem}}".
 *
 * The followings are the available columns in table '{{emaillistitem}}':
 * @property integer $id
 * @property integer $emailListId
 * @property string $recipientType
 * @property string $recipientName
 * @property string $recipientEmail
 *
 * @package
 * @author
 */
class EmailListItem extends MyModel
{
    // {{{ *** Members ***

    /**
     * List of fields composing the record name (separated by ;)
     * @var string
     */
    var $nameFields = "id";

    /**
     * Name format string (e.g. '{1} (#{2})' 
     * @var string
     */
    var $nameFormat = "{1}";
    
    /**
     * Does this model use record revisions?
     * @var bool
     */
    var $usesRevision   = false;

    /**
     * Revision number of current record
     * @var int
     */
    var $recordRevision;

    /**
     * Does this model use logging?
     * @var bool
     */
    var $usesLog        = false;

    Const RECIPIENT_TYPE_TO = '1_To';
    Const RECIPIENT_TYPE_CC = '2_Cc';
    Const RECIPIENT_TYPE_BCC = '3_Bcc';


    // }}} 
    // {{{ *** Methods ***
    // {{{ model
    /**
     * Returns the static model of the specified AR class.
     * @return EmailListItem the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    } // }}} 
    // {{{ tableName
    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return '{{emaillistitem}}';
    } // }}} 
    // {{{ rules
    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('id, emailListId, recipientType, recipientEmail', 'required'),
            array('id, emailListId', 'numerical', 'integerOnly'=>true),
            array('recipientType', 'length', 'max'=>5),
            array('recipientName, recipientEmail', 'length', 'max'=>255),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, emailListId, recipientType, recipientName, recipientEmail', 'safe', 'on'=>'search'),
        );
    } // }}} 
    // {{{ relations
    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    } // }}} 
    // {{{ attributeLabels
    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => Yii::t('site','ID'),
            'emailListId' => Yii::t('site','Email List'),
            'recipientType' => Yii::t('site','Recipient Type'),
            'recipientName' => Yii::t('site','Recipient Name'),
            'recipientEmail' => Yii::t('site','Recipient Email'),
        );
    } // }}} 
    // {{{ search
    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('emailListId',$this->emailListId);
		$criteria->compare('recipientType',$this->recipientType,true);
		$criteria->compare('recipientName',$this->recipientName,true);
		$criteria->compare('recipientEmail',$this->recipientEmail,true);
        return new CActiveDataProvider(get_class($this), array('criteria'=>$criteria));
    } // }}} 
    public function getRecipientTypeOptions()
    {
        return array(
            self::RECIPIENT_TYPE_TO => 'To',
            self::RECIPIENT_TYPE_CC => 'Cc',
            self::RECIPIENT_TYPE_BCC => 'Bcc',
        );  
    } 
    // }}} 
}

/* vim: set ai sw=4 sts=4 et fdm=marker fdc=4 */ 
?>
